package com.easy.modules.sysmgr.entity;

import java.sql.Clob;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.easy.modules.common.RecordEntity;

/**
 * 公司表（有上下级之分） 创建者： 杨浩泉 创建时间： 2014-3-17 下午9:21:03 版本号： v1.0
 */
@Entity
@Table(name = "EASY_SYSMGR_COMPANY")
@DynamicUpdate(true)
@DynamicInsert(true)
public class CompanyEntity extends RecordEntity {

	private String name;				//公司名称
	
	private String code ;				//公司代码
	
	private String tel ;				//联系电话
	
	private String fax ;				//传真号码

	private String area ;				//区域
	
	private String post_code ;			//邮政编码
	
	private String site ;				//公司官网
	
	private String addr ;				//联系地址
	
	private Clob remark ;				//公司简介
	
	private Set<CompanyEntity> companys = new HashSet<CompanyEntity>(0);

	private CompanyEntity company;

	private Set<DeptEntity> dpets = new HashSet<DeptEntity>();
	
	private Set<UserEntity> users = new HashSet<UserEntity>();

	
	@OneToMany
	@JoinColumn(name = "COMPANY_ID")
	public Set<UserEntity> getUsers() {
		return users;
	}

	public void setUsers(Set<UserEntity> users) {
		this.users = users;
	}

	@OneToMany
	@JoinColumn(name = "COMPANY_ID")
	public Set<DeptEntity> getDpets() {
		return dpets;
	}

	public void setDpets(Set<DeptEntity> dpets) {
		this.dpets = dpets;
	}

	@OneToMany(mappedBy = "company", fetch = FetchType.LAZY)
	@OrderBy("created desc")
	public Set<CompanyEntity> getCompanys() {
		return companys;
	}

	public void setCompanys(Set<CompanyEntity> companys) {
		this.companys = companys;
	}

	@ManyToOne
	@JoinColumn(name = "COMPANY_PID")
	public CompanyEntity getCompany() {
		return company;
	}

	public void setCompany(CompanyEntity company) {
		this.company = company;
	}

	public String getPost_code() {
		return post_code;
	}

	public void setPost_code(String post_code) {
		this.post_code = post_code;
	}

	public String getSite() {
		return site;
	}

	public void setSite(String site) {
		this.site = site;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public Clob getRemark() {
		return remark;
	}

	public void setRemark(Clob remark) {
		this.remark = remark;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getFax() {
		return fax;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
